package pl.prv.polanie.client.widgets.schedule.widgets;

import com.google.gwt.user.client.ui.HTML;

public class DayHeader extends HTML {
	
	public DayHeader(String title) {
		super("<center>" + title + "</center>");
	}
	
	
	
	
	/*************************** ramki *****/
	boolean attached = false;

	public void setOffsetWidth(int offsetWidth) {
		validateAttached();
		
		super.setWidth(offsetWidth+"px");
		int w = this.getOffsetWidth();
		
		if (w != offsetWidth) {
//			Window.alert("musialem jeszcze raz setWidth w FF");	
			offsetWidth -= w-offsetWidth; 
			super.setWidth(offsetWidth+"px");
		}
	}

	public void setOffsetHeight(int offsetHeight) {
		validateAttached();
		
		super.setHeight(offsetHeight+"px");
		int h = this.getOffsetHeight();
		
		if (h != offsetHeight) {
			offsetHeight -= h-offsetHeight; 
			super.setHeight(offsetHeight+"px");
		}
	}
	
    private void validateAttached() {
    	if (!attached) {
            throw new IllegalStateException("Widget must be attached first.");
        }
    }
    
    protected void onAttach() {
    	super.onAttach();
    	attached = true;
    }

	
}
